package com.zhuojy.equity.mall.admin.manager;

import java.util.List;

import cn.hutool.core.collection.CollUtil;
import com.zhuojy.equity.mall.admin.common.exception.Asserts;
import com.zhuojy.equity.mall.admin.common.exception.BizException;
import com.zhuojy.equity.mall.admin.dal.dataobject.TResourceDO;
import com.zhuojy.equity.mall.admin.dal.mapper.TResourceMapper;
import lombok.RequiredArgsConstructor;

import org.springframework.stereotype.Component;

/**
 * 资源表数据管理层
 */
@Component
@RequiredArgsConstructor
public class ResourceManager {

	private final TResourceMapper resourceMapper;

	public List<TResourceDO> queryByIdList(List<Long> resourceIdList) throws BizException {
		List<TResourceDO> resourceDOList = resourceMapper.selectByIdList(resourceIdList);
		if (CollUtil.isEmpty(resourceDOList)) {
			Asserts.fail("查询资源列表失败！");
		}
		return resourceDOList;
	}

	public List<TResourceDO> queryAllResource() throws BizException {
		List<TResourceDO> resourceDOList = resourceMapper.selectAll();
		if (CollUtil.isEmpty(resourceDOList)) {
			Asserts.fail("查询资源列表失败！");
		}
		return resourceDOList;
	}
}
